<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 18/11/14
 * Time: 4:19 PM
 */

class Caches  {

    public function __construct() {
        parent::__construct();
    }

    public static function clear($cfile){

        $cache_path = path('storage').'cache/';
        $files = scandir($cache_path);


        Cache::forget($cfile);
        foreach ($files as $file)
        {
            if(static::_startsWith("$cfile", $file) == true ){
                unlink($cache_path.$file);
            }
        }
    }

    static function _startsWith($haystack, $needle)
    {
        $length = strlen($needle);
        $hl = strlen($haystack);
        return (substr($needle,0,$hl) === $haystack);
    }
} 